
**************************************************************************************************;

/* 				   	This file produce the results of Panel B of Table 8 				    	 */

***************************************************************************************************;


libname rep "C:\Users\~";

data regbase; set rep.mydata; run;

option missing = " ";
%macro print;
data N; set N; Estimate = nValue1; if Label1 = "Used"; run;
data Nobs; set N; Parameter = "N"; keep EstType Parameter Estimate; run;
data r2; set fit; Parameter = "RSQ"; keep EstType Parameter RSquare; rename RSquare = Estimate;  run;
data adjr2; set fit; Parameter = "AdjRSQ"; keep EstType Parameter AdjRsq; rename AdjRSq = Estimate;  run;
data final; set parest Nobs r2 adjr2; drop EstType StdErr Probt DF; run;
data final&i; set final; rename Estimate = syy_&freq tValue = t_&freq; 
if Parameter not in ("Unlev_freq", "Lev_freq" "a_freq", "N", "RSQ") then delete; run;
proc print data = final&i noobs; run;
%mend;


%macro decomp ;

%do i=1 %to 2;
%if &i =1 %then %do; %let freq = low; %let con = high; %end; 
%else %do; %let freq = high; %let con = low; %end;
ods output "Nonlinear GMM Summary of Residual Errors" = fit;
ods output "Nonlinear GMM Parameter Estimates" = parest;
ods output "Estimation Summary Statistics" = N;
proc model data=regbase plot =none;
endo syy_&freq; exog active_low active_high Unlev_low Lev_low Unlev_high Lev_high mktrf amihud tover hml smb; instruments _exog_;
syy_&freq =b0 + Unlev_freq * Unlev_&freq + Lev_freq * Lev_&freq + Unlev_con * Unlev_&con + Lev_con * Lev_&con +a_freq * active_&freq + a_con* active_&con 
+b1*mktrf +b2*amihud + b3*tover + b4*hml + b5*smb;
fit syy_&freq / gmm kernel=(bart,13,0) vardef=n; run; quit; 
%print;
%end;

data T8B; merge final1 final2; run;
%mend;

%decomp;

proc print data = T8B noobs; run;

